package com.fy56.platform.logistics.service.impl;

import com.alibaba.fastjson.JSON;
import com.fy56.platform.logistics.common.ResultModel;
import com.fy56.platform.logistics.service.wx.IAreaService;
import com.fy56.platform.logistics.utils.HttpClientUtils;
import com.fy56.platform.logistics.utils.MD5Util;
import com.fy56.platform.logistics.utils.ParamUtil;
import com.fy56.platform.logistics.utils.StringUtil;
import com.google.common.collect.Maps;

import org.springframework.stereotype.Service;

import java.util.Map;

/*
 * @项目名称：
 * @类名称：AreaServiceImpl
 * @类描述：区域网点 AreaServiceImpl 实现
 * @创建人：
 * @作者单位：哈尔滨飞扬软件技术有限公司
 * --------------------------------------
 * @创建时间：2019-04-16 16:54:15
 * @version：1.0.0
 */
@Service
public class AreaServiceImpl implements IAreaService {

    private String url = "http://www.feiyang56.cn/fyhd";

    @Override
    public ResultModel queryAreaListService(String userName, String userPass, Integer pointFlag) throws Exception{
        ResultModel resultModel = null;
        // 1 查询数据库中是否存在该保单
        Map<String, Object> params = Maps.newHashMap();
        params.put("userName", userName);
        params.put("userPass", MD5Util.getMD5Code(userPass).toUpperCase());
        Map<String, Object> contentMap = Maps.newHashMap();
        contentMap.put("currentPage", 1);
        contentMap.put("pageSize", 1000);
        contentMap.put("pointFlag", pointFlag);
        params.put("content", contentMap);

        Map<String, String> searchParams = Maps.newHashMap();
        System.out.println("param-data: " + JSON.toJSONString(params));
        searchParams.put("param", JSON.toJSONString(params));
        String postData = HttpClientUtils.post(url + "/ifs/area_queryAreaList_resultAction.action", searchParams, null, 10000, 10000);
        Integer code = 101; String message = "";
        if(StringUtil.isNotEmpty(postData)){
            Map<String,Object> resultMap = JSON.parseObject(postData);
            resultModel = ParamUtil.getGmmsResultModel(resultMap);
        }
        return resultModel;
    }


}
